package sevensoft.行为型模式.迭代器模式;

import lombok.AllArgsConstructor;

import java.util.List;

public class MyIteratorImpl<T> implements MyIterator<T> {

    private List<T> list;

    public MyIteratorImpl(List<T> list) {
        this.list = list;
    }

    private int index = 0;

    @Override
    public boolean hasNext() {
        return list.size() > index;
    }

    @Override
    public T next() {
        return list.get(++index - 1);
    }
}
